package com.ruoyi.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LabReceiptDetails;
import com.ruoyi.system.service.ILabReceiptDetailsService;

/**
 * receiptDetailsController
 * 
 * @author winner pan
 * @date 2022-05-13
 */
@RestController
@RequestMapping("/system/receiptDetails")
public class LabReceiptDetailsController extends BaseController
{
    @Autowired
    private ILabReceiptDetailsService labReceiptDetailsService;

    /**
     * 查询receiptDetails列表
     */
    @PreAuthorize("@ss.hasPermi('labbase:receipt_form:query')")
    @GetMapping("/list")
    public AjaxResult list(LabReceiptDetails labReceiptDetails){
        return AjaxResult.success(labReceiptDetailsService.selectLabReceiptDetailsList(labReceiptDetails));
    }

    /**
     * 导出receiptDetails列表
     */
    /*@PreAuthorize("@ss.hasPermi('system:receiptDetails:export')")
    @Log(title = "receiptDetails", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabReceiptDetails labReceiptDetails)
    {
        List<LabReceiptDetails> list = labReceiptDetailsService.selectLabReceiptDetailsList(labReceiptDetails);
        ExcelUtil<LabReceiptDetails> util = new ExcelUtil<LabReceiptDetails>(LabReceiptDetails.class);
        return util.exportExcel(list, "receiptDetails");
    }
*/
    /**
     * 获取receiptDetails详细信息
     */
    @PreAuthorize("@ss.hasPermi('labbase:receipt_form:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return AjaxResult.success(labReceiptDetailsService.selectLabReceiptDetailsById(detailId));
    }

    /**
     * 新增receiptDetails
     */
    @PreAuthorize("@ss.hasPermi('labbase:receipt_form:edit')")
    @Log(title = "receiptDetails", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabReceiptDetails labReceiptDetails)
    {
        return AjaxResult.success(labReceiptDetailsService.insertLabReceiptDetails(labReceiptDetails));
    }

    /**
     * 修改receiptDetails
     */
    @PreAuthorize("@ss.hasPermi('labbase:receipt_form:edit')")
    @Log(title = "receiptDetails", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabReceiptDetails labReceiptDetails)
    {
        return AjaxResult.success(labReceiptDetailsService.updateLabReceiptDetails(labReceiptDetails));
    }

    /**
     * 删除receiptDetails
     */
    @PreAuthorize("@ss.hasPermi('labbase:receipt_form:edit')")
    @Log(title = "receiptDetails", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailId}")
    public AjaxResult remove(@PathVariable Long detailId)
    {
        return AjaxResult.success(labReceiptDetailsService.deleteLabReceiptDetailsById(detailId));
    }
}
